(function() {
  $(function() {
    var refresh;
    window.id = 0;
    refresh = function() {
      return $.getJSON('/Home/Chat/refresh', {
        id: window.id
      }, function(data) {
        var index;
        if (data.length === 0) {
          return false;
        }
        index = data.length - 1;
        window.id = data[index].id;
        return $.each(data, function(k, v) {
          var html;
          html = "<li class='am-comment'> <article class='am-comment'> <a href='#link-to-user-home'> <img src='' alt='' class='am-comment-avatar' width='48' height='48'/> </a> <div class='am-comment-main'> <header class='am-comment-hd'> <!--<h3 class='am-comment-title'>评论标题</h3>--> <div class='am-comment-meta'> <a href='#link-to-user' class='am-comment-author'>" + v.username + "</a> 评论于 <time datetime='2013-07-27T04:54:29-07:00' title='2013年7月27日 下午7:54 格林尼治标准时间+0800'> " + v.time + " </time> </div> </header> <div class='am-comment-bd'> " + v.content + " </div> </div> </article> </li>";
          $(".am-comments-list").append(html);
          return $(".am-panel-bd").animate({
            scrollTop: $(".am-comments-list").height()
          });
        });
      });
    };
    setInterval(refresh, 1000);
    return $("#submit").click(function() {
      $.post('/Home/Chat/store', $(".add_comment").serialize());
      return false;
    });
  });

}).call(this);
